#define _CRT_SECURE_NO_WARNINGS 1


#include<vector>
#include<iostream>

using namespace std;

vector<int> productExceptSelf(vector<int>& nums)
{
    int size = nums.size();
    vector<int> v(size);
    vector<int> front(size), rear(size);
    front[0] = rear[size - 1] = 1;
    for (int i = 1; i < size; i++)
    {
        front[i] = front[i - 1] * nums[i - 1];
    }
    for (int i = size - 2; i >= 0; i--)
    {
        rear[i] = rear[i + 1] * nums[i + 1];
    }
    for (int i = 0; i < size; i++)
    {
        v[i] = front[i] * rear[i];
    }
    return v;
}